<template>
	<view class="container">
		<!-- 顶部导航栏 -->
		<u-navbar
			title="详情"
			:autoBack="true"
			:fixed="true"
			:placeholder="true"
			:bgColor="navBgColor"
			:titleStyle="{
				color: '#333',
				fontSize: '16px',
			}"
		>
			<template #right>
				<view class="nav-right">
					<button class="share-btn" open-type="share">
						<u-icon name="more-dot-fill" size="20" color="#333"></u-icon>
					</button>
				</view>
			</template>
		</u-navbar>

		<!-- 轮播图 -->
		<view class="swiper-box">
			<swiper class="swiper" :indicator-dots="true" indicator-color="rgba(255, 255, 255, 0.6)" indicator-active-color="#fff">
				<swiper-item>
					<!-- <image src="@/static/img-index/product.jpg" mode="aspectFill"></image> -->
				</swiper-item>
			</swiper>
			<view class="image-count">图片 1/1</view>
		</view>
		<view class="content">
			<!-- 价格标题区 -->
			<view class="price-section">
				<view class="price">
					<text class="symbol">¥</text>
					<text class="number">1100</text>
					<text class="unit">/月</text>
				</view>
				<view class="title">精装阳光大单间柯木仙贝坪揽排街31号</view>
				<view class="review">暂无评价 ></view>
			</view>

			<!-- 房源信息 -->
			<view class="info-section">
				<view class="section-title">房源信息</view>
				<view class="info-grid">
					<view class="info-item">
						<text class="label">面积</text>
						<text class="value">30m²</text>
					</view>
					<view class="info-item">
						<text class="label">户型</text>
						<text class="value">2楼</text>
					</view>
					<view class="info-item">
						<text class="label">楼层</text>
						<text class="value">第二层</text>
					</view>
					<view class="info-item">
						<text class="label">朝向</text>
						<text class="value">南</text>
					</view>
					<view class="info-item">
						<text class="label">类型</text>
						<text class="value">英东花园</text>
					</view>
					<view class="info-item">
						<text class="label">入住</text>
						<text class="value">随时入住</text>
					</view>
					<view class="info-item">
						<text class="label">装修</text>
						<text class="value">精装修</text>
					</view>
					<view class="info-item">
						<text class="label">付款</text>
						<text class="value">押一付二</text>
					</view>
				</view>
			</view>

			<!-- 费用详情 -->
			<view class="cost-section">
				<view class="section-title">费用详情</view>
				<view class="cost-list">
					<view class="cost-item">
						<text class="label">押金</text>
						<text class="value">¥2200</text>
					</view>
					<view class="cost-item">
						<text class="label">水费</text>
						<text class="value">¥5/吨 (月)</text>
					</view>
					<view class="cost-item">
						<text class="label">电费</text>
						<text class="value">¥1/kwh (月)</text>
					</view>
				</view>
			</view>

			<!-- 房源设施 -->
			<view class="facility-section">
				<view class="section-title">房源设施</view>
				<view class="facility-grid">
					<view class="facility-item" v-for="(item, index) in facilities" :key="index">
						<image :src="item.icon" mode="" style="width: 64rpx;height:64rpx;"></image>
						<text>{{ item.name }}</text>
					</view>
				</view>
			</view>

			<!-- 位置及周边 -->
			<view class="location-section">
				<view class="section-header">
					<text class="section-title">位置及周边</text>
					<text class="more">查看地图 ></text>
				</view>
				<view class="address">
					<u-icon name="map-fill" size="32" color="#2979ff"></u-icon>
					<text>柯木朗新村坪揽排街31号-精装阳光大单间</text>
				</view>
				<image class="map-image" src="/static/images/map.png" mode="aspectFill"></image>
				<view class="poi-list">
					<view class="poi-item">
						<view class="name">地铁站</view>
						<view class="poi-item-content">
							<view class="poi-item-info">
								<text class="station">柯木朗</text>
								<text class="distance">298.78m</text>
							</view>
							<view class="poi-item-info">
								<text class="name">龙洞</text>
								<text class="distance">1660.94m</text>
							</view>
							<view class="poi-item-info">
								<text class="name">高塘石</text>
								<text class="distance">1700.14m</text>
							</view>
						</view>
					</view>
					<view class="poi-item">
						<text class="name">公交站</text>
						<view class="poi-item-content">
							<view class="poi-item-info">
								<text class="station">柯木朗</text>
								<text class="distance">278.45m</text>
							</view>
							<view class="poi-item-info">
								<text class="name">地铁站体育西</text>
								<text class="distance">384.65m</text>
							</view>
							<view class="poi-item-info">
								<text class="name">元岗街</text>
								<text class="distance">530.43m</text>
							</view>
						</view>
					</view>
				</view>
			</view>

			<!-- 入住须知 -->
			<view class="notice-section">
				<view class="section-title">入住须知</view>
				<view class="notice-content">需提前预约看房，联系房东</view>
			</view>

			<!-- 房源评价 -->
			<view class="review-section">
				<view class="section-title">房源评价</view>
				<view class="empty-review">
					<image src="/static/images/empty-review.png" mode="aspectFit"></image>
					<text>还没有评论，快来评论</text>
					<button class="review-btn">去评论</button>
				</view>
			</view>

			<!-- 相似房源 -->
			<view class="similar-section">
				<view class="section-title">附近房源</view>
				<scroll-view class="similar-list" scroll-x>
					<view class="similar-item" v-for="(item, index) in similarHouses" :key="index">
						<image :src="item.image" mode="aspectFill"></image>
						<view class="similar-info">
							<view class="title">{{ item.title }}</view>
							<view class="tags">
								<text v-for="(tag, tagIndex) in item.tags" :key="tagIndex">{{ tag }}</text>
							</view>
							<view class="price">
								<text class="symbol">¥</text>
								<text class="number">{{ item.price }}</text>
								<text class="unit">/月</text>
							</view>
						</view>
					</view>
				</scroll-view>
			</view>

			<!-- 底部按钮 -->
			<view class="bottom-bar">
				<button class="contact-btn phone">电话咨询</button>
				<button class="contact-btn chat">在线沟通</button>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			facilities: [
				{ icon: this.$Config.HTTP_REQUEST_URL+"/img/module_icon1.png", name: "冰箱" },
				{ icon: this.$Config.HTTP_REQUEST_URL+"/img/module_icon2.png", name: "洗衣机" },
				{ icon: this.$Config.HTTP_REQUEST_URL+"/img/module_icon3.png", name: "热水器" },
				{ icon: this.$Config.HTTP_REQUEST_URL+"/img/module_icon4.png", name: "宽带" },
				{ icon: this.$Config.HTTP_REQUEST_URL+"/img/module_icon5.png", name: "沙发" },
				{ icon: this.$Config.HTTP_REQUEST_URL+"/img/module_icon6.png", name: "油烟机" },
				{ icon: this.$Config.HTTP_REQUEST_URL+"/img/module_icon7.png", name: "空调" },
				{ icon: this.$Config.HTTP_REQUEST_URL+"/img/module_icon8.png", name: "衣柜" },
				{ icon: this.$Config.HTTP_REQUEST_URL+"/img/module_icon9.png", name: "床" },
				{ icon: this.$Config.HTTP_REQUEST_URL+"/img/module_icon10.png", name: "卫生间" },
				{ icon: this.$Config.HTTP_REQUEST_URL+"/img/module_icon11.png", name: "智能门锁" },
				{ icon: this.$Config.HTTP_REQUEST_URL+"/img/module_icon12.png", name: "阳台" },
				{ icon: this.$Config.HTTP_REQUEST_URL+"/img/module_icon13.png", name: "书桌" },
			],
			similarHouses: [
				{
					image: "/static/images/house.jpg",
					title: "精装阳光大单间柯木仙贝坪揽排街31号",
					tags: ["交通便利", "近商场", "近公交"],
					price: "1100",
				},
				{
					image: "/static/images/house.jpg",
					title: "精装阳光大单间柯木仙贝坪揽排街31号",
					tags: ["交通便利", "近商场", "近公交"],
					price: "1100",
				},
			],
			scrollTop: 0,
			navBgColor: "transparent",
		};
	},
	onPageScroll(e) {
		// 获取滚动距离
		this.scrollTop = e.scrollTop;
		// 设置渐变的阈值，这里设置200rpx
		const threshold = 200;
		if (this.scrollTop > threshold) {
			// 超过阈值，设置白色背景
			this.navBgColor = "#ffffff";
		} else {
			// 计算透明度
			const alpha = this.scrollTop / threshold;
			// 设置半透明背景色
			this.navBgColor = `rgba(255, 255, 255, ${alpha})`;
		}
	},
};
</script>

<style lang="less" scoped>
.container {
	min-height: 100vh;
	background: #f5f6fa;
	padding-bottom: 120rpx;
}

.swiper-box {
	position: relative;

	.swiper {
		width: 100%;
		height: 500rpx;

		image {
			width: 100%;
			height: 100%;
		}
	}

	.image-count {
		position: absolute;
		right: 24rpx;
		bottom: 24rpx;
		padding: 4rpx 16rpx;
		background: rgba(0, 0, 0, 0.4);
		border-radius: 100rpx;
		color: #fff;
		font-size: 24rpx;
	}
}
.content {
	width: 100%;
	height: auto;
	overflow: hidden;
	padding: 0 40rpx;
	box-sizing: border-box;
	background: #ffffff;
	border-radius: 40rpx 40rpx 0rpx 0rpx;
}
.price-section {
	padding: 24rpx 0;
	background: #fff;

	.price {
		margin-bottom: 16rpx;

		.symbol {
			font-size: 28rpx;
			color: #ff5a5f;
		}

		.number {
			font-size: 40rpx;
			color: #ff5a5f;
			font-weight: 500;
		}

		.unit {
			font-size: 24rpx;
			color: #999;
		}
	}

	.title {
		font-size: 32rpx;
		color: #333;
		margin-bottom: 16rpx;
	}

	.review {
		font-size: 24rpx;
		color: #999;
	}
}

.section-title {
	font-size: 32rpx;
	color: #333;
	font-weight: 500;
	margin-bottom: 24rpx;
}

.info-section {
	margin-top: 24rpx;
	padding: 24rpx 0;
	background: #fff;

	.info-grid {
		display: grid;
		grid-template-columns: repeat(2, 1fr);
		gap: 24rpx;

		.info-item {
			display: flex;
			justify-content: flex-start;
			align-items: center;

			.label {
				font-size: 28rpx;
				color: #999;
				margin-right: 10rpx;
			}

			.value {
				font-size: 28rpx;
				color: #333;
			}
		}
	}
}

.cost-section {
	margin-top: 24rpx;
	padding: 24rpx 0;
	background: #fff;

	.cost-list {
		.cost-item {
			display: flex;
			justify-content: space-between;
			align-items: center;
			margin-bottom: 24rpx;

			&:last-child {
				margin-bottom: 0;
			}

			.label {
				font-size: 28rpx;
				color: #999;
			}

			.value {
				font-size: 28rpx;
				color: #333;
			}
		}
	}
}

.facility-section {
	margin-top: 24rpx;
	padding: 24rpx 0;
	background: #fff;

	.facility-grid {
		display: grid;
		grid-template-columns: repeat(5, 1fr);
		gap: 24rpx;

		.facility-item {
			display: flex;
			flex-direction: column;
			align-items: center;

			text {
				font-size: 24rpx;
				color: #666;
				margin-top: 12rpx;
			}
		}
	}
}

.location-section {
	margin-top: 24rpx;
	padding: 24rpx 0;
	background: #fff;

	.section-header {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 24rpx;

		.more {
			font-size: 26rpx;
			color: #2979ff;
		}
	}

	.address {
		display: flex;
		align-items: center;
		margin-bottom: 24rpx;

		text {
			flex: 1;
			font-size: 28rpx;
			color: #333;
			margin-left: 12rpx;
		}
	}

	.map-image {
		width: 100%;
		height: 300rpx;
		border-radius: 12rpx;
		margin-bottom: 24rpx;
	}

	.poi-list {
		.poi-item {
			display: flex;
			justify-content: space-between;
			margin-bottom: 16rpx;
			&:last-child {
				margin-bottom: 0;
			}

			.name {
				font-size: 28rpx;
				color: #333;
				width: 180rpx;
			}
			.poi-item-content {
				flex: 1;
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				.poi-item-info{
					display: flex;
					justify-content: space-between;
				}
			}

			.station {
				flex: 1;
				font-size: 28rpx;
				color: #666;
			}

			.distance {
				font-size: 28rpx;
				color: #999;
			}
		}
	}
}

.notice-section {
	margin-top: 24rpx;
	padding: 24rpx 0;
	background: #fff;

	.notice-content {
		font-size: 28rpx;
		color: #666;
	}
}

.review-section {
	margin-top: 24rpx;
	padding: 24rpx 0;
	background: #fff;

	.empty-review {
		display: flex;
		flex-direction: column;
		align-items: center;
		padding: 48rpx 0;

		image {
			width: 200rpx;
			height: 200rpx;
			margin-bottom: 24rpx;
		}

		text {
			font-size: 28rpx;
			color: #999;
			margin-bottom: 24rpx;
		}

		.review-btn {
			width: 200rpx;
			height: 72rpx;
			line-height: 72rpx;
			background: #2979ff;
			color: #fff;
			font-size: 28rpx;
			border-radius: 36rpx;
		}
	}
}

.similar-section {
	margin-top: 24rpx;
	padding: 24rpx 0;
	background: #fff;

	.similar-list {
		white-space: nowrap;

		.similar-item {
			display: inline-block;
			width: 300rpx;
			margin-right: 24rpx;

			&:last-child {
				margin-right: 0;
			}

			image {
				width: 100%;
				height: 200rpx;
				border-radius: 12rpx;
			}

			.similar-info {
				padding: 16rpx 0;

				.title {
					font-size: 28rpx;
					color: #333;
					margin-bottom: 12rpx;
					white-space: normal;
					display: -webkit-box;
					-webkit-line-clamp: 2;
					-webkit-box-orient: vertical;
					overflow: hidden;
				}

				.tags {
					margin-bottom: 12rpx;

					text {
						display: inline-block;
						padding: 4rpx 12rpx;
						background: #f7f8fa;
						color: #666;
						font-size: 22rpx;
						border-radius: 4rpx;
						margin-right: 8rpx;
						margin-bottom: 8rpx;
					}
				}

				.price {
					.symbol {
						font-size: 24rpx;
						color: #ff5a5f;
					}
					.number {
						font-size: 32rpx;
						color: #ff5a5f;
						font-weight: 500;
					}
					.unit {
						font-size: 22rpx;
						color: #999;
					}
				}
			}
		}
	}
}

.bottom-bar {
	height: 100rpx;
	background: #fff;
	display: flex;
	align-items: center;
	padding: 0 24rpx;
	box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.05);

	.contact-btn {
		flex: 1;
		height: 72rpx;
		line-height: 72rpx;
		text-align: center;
		font-size: 28rpx;
		border-radius: 36rpx;
		margin: 0 12rpx;

		&.phone {
			background: #fff;
			color: #2979ff;
			border: 2rpx solid #2979ff;
		}

		&.chat {
			background: #2979ff;
			color: #fff;
		}
	}
}
</style>
